<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8" />
    <title>dotProject</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta
            name="viewport"
            content="width=device-width, initial-scale=1, maximum-scale=1"
    />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <link rel="stylesheet" href="__STATIC__/amis/v1.2.2/cxd.css" />
    <link rel="stylesheet" href="__STATIC__/amis/v1.2.2/helper.css" />
    <!-- 从 1.1.0 开始 sdk.css 将不支持 IE 11，如果要支持 IE11 请引用这个 css，并把前面那个删了 -->
    <!-- <link rel="stylesheet" href="sdk-ie11.css" /> -->
    <!-- 不过 amis 开发团队几乎没测试过 IE 11 下的效果，所以可能有细节功能用不了，如果发现请报 issue -->
    <style>
        html,
        body,
        .app-wrapper {
            position: relative;
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
        }
    </style>
</head>
<body>
<div id="root" class="app-wrapper"></div>
<script src="__STATIC__/node_modules/route-recognizer/dist/route-recognizer.js"></script>
<script src="__STATIC__/amis/v1.2.2/sdk.js"></script>
<script type="text/javascript">
    (function () {
        var router = new RouteRecognizer();
        router.add([{
            path: "/table/:model/*pathVar",
            handler: function (args) {
                console.log('default handler', args)
            }
        }]);

        var hash = window.location.hash.split('#')[1];
        // console.log('recognize target', hash)

        var result = router.recognize(hash);
        // console.log('recognize result', result)
        // result === [{ params: { model: 'xyz',  path: "hello/world" }, handler: handler  }];
        // console.log('recognize result length', result.length)
        var defaultModel = 'Project';
        var currentModel = (result.length > 0) ? result[0].params.model : defaultModel;
        var schemaApi = "{:url('/lc/build/table/:model')->suffix(false)}".replace(/:\w+/g, function(model) {
            return currentModel;
        });

        let amis = amisRequire('amis/embed');
        // 通过替换下面这个配置来生成不同页面
        let amisJSON = {
            type: 'page',
            title: '数据管理',
            body: {
                type: 'service',
                schemaApi: schemaApi,
            },
        };
        let amisScoped = amis.embed('#root', amisJSON, {}, {
            theme: 'cxd'
        });
    })();
</script>
</body>
</html>